package com.wowangz.cms.topic.news.service;

import java.util.List;
import java.util.Map;

import com.wowangz.cms.syscore.exception.ServiceException;
import com.wowangz.cms.syscore.service.BaseService;
import com.wowangz.cms.topic.news.entity.News;

public class NewsService extends BaseService {

	/**
	 * 保存新闻内容
	 * 
	 * @param news
	 */
	public void saveNews(News news) throws ServiceException {
		try {
			this.getSqlSession().insert("NewsService.saveNews", news);
		} catch (ServiceException e) {
			throw new ServiceException(e.getMessage());
		}
	}

	/**
	 * 修改新闻内容
	 * 
	 * @param news
	 * @throws ServiceException
	 */
	public void updateNews(News news) throws ServiceException {
		try {
			this.getSqlSession().update("NewsService.updateNews", news);
		} catch (ServiceException e) {
			throw new ServiceException(e.getMessage());
		}
	}

	/**
	 * 删除新闻内容
	 * 
	 * @param news
	 * @throws ServiceException
	 */
	public void deleteNews(News news) throws ServiceException {
		try {
			this.getSqlSession().update("NewsService.updateNews", news);
		} catch (ServiceException e) {
			throw new ServiceException(e.getMessage());
		}
	}
	/**
	 * 查询一条记录
	 * @param paramMap
	 * @return
	 * @throws ServiceException
	 */
	public News findOneNewsByMap(Map<String, Object> paramMap) throws ServiceException{
		try {
			return this.getSqlSession().selectOne("NewsService.findOneNewsByMap", paramMap);
		} catch (ServiceException e) {
			throw new ServiceException(e.getMessage());
		}
	}
	
	/**
	 * 查询记录的总数
	 * @param paramMap
	 * @return
	 * @throws ServiceException
	 */
	public Long findNewsCountByMap(Map<String, Object> paramMap) throws ServiceException{
		try {
			return this.getSqlSession().selectOne("NewsService.findNewsCountByMap", paramMap);
		} catch (ServiceException e) {
			throw new ServiceException(e.getMessage());
		}
	}
	
	/**
	 * 查询记录的集合
	 * @param paramMap
	 * @return
	 * @throws ServiceException
	 */
	public List<News> findNewsPageByMap(Map<String, Object> paramMap) throws ServiceException{
		try {
			return this.getSqlSession().selectList("NewsService.findNewsPageByMap", paramMap);
		} catch (ServiceException e) {
			throw new ServiceException(e.getMessage());
		}
	}
	
}
